
/*
 *  Copyright (c) 2013.
 *  * 游戏服务器核心代码编写人陈磊拥有使用权
 *  * 联系方式：E-mail:13638363871@163.com ;qq:502959937
 *  * 个人博客主页：http://my.oschina.net/chenleijava
 */

package com.dc.gameserver.serverCore.controller.handleController;

import com.dc.gameserver.proto.gameserverprotoVo.verifySystemTimeRequest;
import com.dc.gameserver.proto.gameserverprotoVo.verifySystemTimeResponse;
import com.dc.gameserver.serverCore.controller.AbstractController.AbstractController;
import com.dc.gameserver.serverCore.controller.AbstractController.IController;
import com.dc.gameserver.serverCore.service.character.PlayerInstance;
import com.google.protobuf.MessageLite;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * @author : 石头哥哥
 *         Project : LandlordsServer
 *         Date: 13-6-4
 *         Time: 上午11:49
 *         Connect: 13638363871@163.com
 *         packageName: Server.ServerCore.Controller
 *         系统时间校验
 */
@Service
public class verifySystemTimeController extends AbstractController {


    @Override
    public void PostConstruct() {
        int ID= verifySystemTimeRequest.msgID.ID_VALUE;
        GAME_CONTROLLERS[ID]=this;
        IController.MESSAGE_LITE[ID]= verifySystemTimeRequest.getDefaultInstance();
    }

     /**
     * messageLite数据结构体分发
     * @param messageLite
     * @param player
     * @throws Exception
      *
     */
    @Override
    public void DispatchMessageLit(MessageLite messageLite, PlayerInstance player) throws Exception {
        messageLite=null;
        verifySystemTimeResponse.Builder builder=verifySystemTimeResponse.newBuilder();
        builder.setSystemTime(new Date().getTime());
        player.DirectSend(wrappedBufferShort(verifySystemTimeResponse.msgID.ID_VALUE,builder.build()));
    }
}
